package com.kaifamiao.www.demo.do0812;

import java.util.List;
import java.util.Vector;

public class ListDemp {
    public static void main(String[] args) {
        Vector vector = new Vector();

        vector.add("a");
        vector.add("b");
        vector.add("c");
        vector.add("d");
        vector.add("f");

        vector.add(1,"z");
        System.out.println(vector);

        List list = vector.subList(2,4);
        list.add("v");
        System.out.println(list);

        Object old = vector.set(1,"Q");
        vector.setElementAt("W",2);

        System.out.println("原来的值是："+old);
        System.out.println(vector);

        //删除索引为 0 的元素
        Object remove = vector.remove(0);
        System.out.println("被删除的是："+remove);
        //删除 “c”元素  true 成功  false  失败
        boolean flag = vector.remove("c");
        System.out.println(flag);
        System.out.println(vector);

    }
}
